package com.scalar.chiptrack.operations.shippingRequest;

import com.scalar.chiptrack.commons.Address;

import java.io.Serializable;
import java.util.ArrayList;




public class ShippingRequest implements Serializable
{
    public static final String STAUS_APPROVED = "Approved";
	public static final String STAUS_CANCELLED = "Cancelled";
    public static final String STAUS_CLOSED = "Closed";

    private int shipRequestId       = -1;
    private int  processStepId      = -1 ;
    private int  fromLocationId     = -1 ;
    private int shipTolocationId    = -1;
    private String partNumber       = null;
	private String vendorName       = null;
    private int shipperId           = -1;
    private String status           = null;
    private int year                = -1;
    private String shipperName      = null;
    private String shipReqNumber    = null;
    private String shipReqDate      = null;
    private String fromVendorName   = null;
    private String toVendorName     = null;
    private String specialInstr     = null;
    private Address fromVendorAddress = null;
    private Address toVendorAddress   = null;
    private ArrayList lotList   = null;
    private ArrayList shippersList = null;
    private int totalQty             = 0;

    private int qtyPulled           = -1;
    private String lotNumber        = null;
    private int lotId               = -1;
    private String shipAlerts       = null;


    public ShippingRequest()
    {

    }

    public int getProcessStepId() {
        return processStepId;
    }

    public void setProcessStepId(int processStepId) {
        this.processStepId = processStepId;
    }

    public int getFromLocationId() {
        return fromLocationId;
    }

    public void setFromLocationId(int fromLocationId) {
        this.fromLocationId = fromLocationId;
    }

    public int getShipTolocationId() {
        return shipTolocationId;
    }

    public void setShipTolocationId(int shipTolocationId) {
        this.shipTolocationId = shipTolocationId;
    }

    public String getPartNumber() {
        return partNumber;
    }

    public void setPartNumber(String partNumber) {
        this.partNumber = partNumber;
    }

    public String getVendorName() {
        return vendorName;
    }

    public void setVendorName(String vendorName) {
        this.vendorName = vendorName;
    }

    public int getShipperId() {
        return shipperId;
    }

    public void setShipperId(int shipperId) {
        this.shipperId = shipperId;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public String getShipperName() {
        return shipperName;
    }

    public void setShipperName(String shipperName) {
        this.shipperName = shipperName;
    }

    public String getShipReqNumber() {
        return shipReqNumber;
    }

    public void setShipReqNumber(String shipReqNumber) {
        this.shipReqNumber = shipReqNumber;
    }

    public String getShipReqDate() {
        return shipReqDate;
    }

    public void setShipReqDate(String shipReqDate) {
        this.shipReqDate = shipReqDate;
    }

    public String getFromVendorName() {
        return fromVendorName;
    }

    public void setFromVendorName(String fromVendorName) {
        this.fromVendorName = fromVendorName;
    }

    public String getToVendorName() {
        return toVendorName;
    }

    public void setToVendorName(String toVendorName) {
        this.toVendorName = toVendorName;
    }

    public String getSpecialInstr() {
        return specialInstr;
    }

    public void setSpecialInstr(String specialInstr) {
        this.specialInstr = specialInstr;
    }

    public Address getFromVendorAddress() {
        return fromVendorAddress;
    }

    public void setFromVendorAddress(Address fromVendorAddress) {
        this.fromVendorAddress = fromVendorAddress;
    }

    public Address getToVendorAddress() {
        return toVendorAddress;
    }

    public void setToVendorAddress(Address toVendorAddress) {
        this.toVendorAddress = toVendorAddress;
    }

    public ArrayList getLotList() {
        return lotList;
    }

    public void setLotList(ArrayList lotList) {
        this.lotList = lotList;
    }

    public ArrayList getShippersList() {
        return shippersList;
    }

    public void setShippersList(ArrayList shippersList) {
        this.shippersList = shippersList;
    }

    public int getShipRequestId() {
        return shipRequestId;
    }

    public void setShipRequestId(int shipRequestId) {
        this.shipRequestId = shipRequestId;
    }

    public int getQtyPulled() {
        return qtyPulled;
    }

    public void setQtyPulled(int qtyPulled) {
        this.qtyPulled = qtyPulled;
    }

    public String getLotNumber() {
        return lotNumber;
    }

    public void setLotNumber(String lotNumber) {
        this.lotNumber = lotNumber;
    }

    public int getLotId() {
        return lotId;
    }

    public void setLotId(int lotId) {
        this.lotId = lotId;
    }

    public int getTotalQty() {
        return totalQty;
    }

    public void setTotalQty(int totalQty) {
        this.totalQty = totalQty;
    }

    public String getShipAlerts() {
        return shipAlerts;
    }

    public void setShipAlerts(String shipAlerts) {
        this.shipAlerts = shipAlerts;
    }

    public String getFromLocationAddressAsHTML()
    {
        StringBuffer formatfromVendorAddress = new StringBuffer();

        if( fromVendorAddress != null )
        {
            if( fromVendorAddress.getAddress1() != null && ( fromVendorAddress.getAddress1().trim().length() != 0 ) ){
                formatfromVendorAddress.append ( fromVendorAddress.getAddress1() );
            }
            if( fromVendorAddress.getAddress1() != null && ( fromVendorAddress.getAddress1().trim().length() != 0 )
                && fromVendorAddress.getAddress2() != null && ( fromVendorAddress.getAddress2().trim().length() != 0 ) ){
                formatfromVendorAddress.append ( ", " );
            }
            if( fromVendorAddress.getAddress2() != null && ( fromVendorAddress.getAddress2().trim().length() != 0 ) ){
                formatfromVendorAddress.append ( fromVendorAddress.getAddress2() );
            }
            if( ( fromVendorAddress.getAddress3() != null && !"".equalsIgnoreCase(fromVendorAddress.getAddress3().trim()) )
                  || ( fromVendorAddress.getAddress4() != null && !"".equalsIgnoreCase(fromVendorAddress.getAddress4().trim()) ) ) {
                formatfromVendorAddress.append ( "<BR>" );
            }
            if( fromVendorAddress.getAddress3() != null && ( fromVendorAddress.getAddress3().trim().length() != 0 ) ){
                formatfromVendorAddress.append ( fromVendorAddress.getAddress3 () );
            }
            if( fromVendorAddress.getAddress3() != null && !"".equals(fromVendorAddress.getAddress3().trim())
                && fromVendorAddress.getAddress4() != null && !"".equals(fromVendorAddress.getAddress4().trim())) {
                formatfromVendorAddress.append ( ", " );
            }
            if( fromVendorAddress.getAddress4() != null && ( fromVendorAddress.getAddress4().trim().length() != 0 ) ){
                formatfromVendorAddress.append ( fromVendorAddress.getAddress4 () );
            }

            StringBuffer cityStateZip = new StringBuffer ( "" );

            if ( fromVendorAddress.getCity() != null && !"".equals( fromVendorAddress.getCity() ) ) {
                cityStateZip.append ( fromVendorAddress.getCity () );
            }

            // fromVendorAddress ',' only if city, state, zip are not empty
            if ( fromVendorAddress.getCity() != null && !"".equals( fromVendorAddress.getCity() )
                 && ( (  fromVendorAddress.getState() != null && !"".equals(fromVendorAddress.getState()))
                 || ( fromVendorAddress.getZipCode()!= null  && !"".equals(fromVendorAddress.getZipCode())) ) ) {
                cityStateZip.append ( ", " );
            }

            if ( fromVendorAddress.getState() != null && !"".equals( fromVendorAddress.getState() ) ) {
                cityStateZip.append( fromVendorAddress.getState () );
            }

            // Add '-' only if there is state and Zip also
            if ( fromVendorAddress.getState() != null && !"".equals( fromVendorAddress.getState() )
                 && fromVendorAddress.getZipCode () != null && !"".equals( fromVendorAddress.getZipCode () ) ) {
                cityStateZip.append ( " - " );
            }

            if ( fromVendorAddress.getZipCode()!= null && !"".equals( fromVendorAddress.getZipCode() ) ) {
                cityStateZip.append ( fromVendorAddress.getZipCode () );
            }

            // fromVendorAddress ',' if any of the above is present
            if ( (  ( fromVendorAddress.getCity() != null && !"".equals(fromVendorAddress.getCity())  )
                    || ( fromVendorAddress.getState() != null && !"".equals(fromVendorAddress.getState()) )
                    || ( fromVendorAddress.getZipCode() != null &&  !"".equals(fromVendorAddress.getZipCode()) ) )
                    && fromVendorAddress.getCountry() != null && !"".equalsIgnoreCase( fromVendorAddress.getCountry() ) )

            {
                cityStateZip.append ( ", " );
                cityStateZip.append ( fromVendorAddress.getCountry () );
            }
            else  if ( fromVendorAddress.getCountry() != null && !"".equals(fromVendorAddress.getCountry() ) ) // added by sujan on 23rd dec 2004. if city,state,zipcode r empty
            {
                cityStateZip.append ( fromVendorAddress.getCountry() );
            }
            if( cityStateZip != null && cityStateZip.toString().trim().length() > 0  )
            {
                formatfromVendorAddress.append ( "<BR>" + cityStateZip );
            }

            StringBuffer phFax = new StringBuffer ();

            if( fromVendorAddress.getPhoneNumber() != null && !"".equals( fromVendorAddress.getPhoneNumber() ) ) {
                phFax.append ( "T: " + fromVendorAddress.getPhoneNumber () );
            }

            if( fromVendorAddress.getPhoneNumber() != null && !"".equals( fromVendorAddress.getPhoneNumber() )
                &&  fromVendorAddress.getFaxNumber() != null && !"".equals ( fromVendorAddress.getFaxNumber() ) ) {
                phFax.append ( ",&nbsp;" );
            }

            if( fromVendorAddress.getFaxNumber() != null && !"".equals( fromVendorAddress.getFaxNumber() ) ) {
                phFax.append ( "F: " + fromVendorAddress.getFaxNumber () );
            }

            if( phFax != null && phFax.toString().trim().length() > 0  ) {
                formatfromVendorAddress.append ( "<BR>" + phFax );
            }

            if(  fromVendorAddress.getEmail() != null && fromVendorAddress.getEmail().trim().length() > 0 ) {
                formatfromVendorAddress.append ( "<BR>" +  "Email: "+ fromVendorAddress.getEmail() );
            }

        }

        return formatfromVendorAddress.toString();
    }

     public String getToLocationAddressAsHTML()
    {
        StringBuffer formattoVendorAddress = new StringBuffer();

        if( toVendorAddress != null )
        {
            if( toVendorAddress.getAddress1() != null && ( toVendorAddress.getAddress1().trim().length() != 0 ) ){
                formattoVendorAddress.append ( toVendorAddress.getAddress1() );
            }
            if( toVendorAddress.getAddress1() != null && ( toVendorAddress.getAddress1().trim().length() != 0 )
                && toVendorAddress.getAddress2() != null && ( toVendorAddress.getAddress2().trim().length() != 0 ) ){
                formattoVendorAddress.append ( ", " );
            }
            if( toVendorAddress.getAddress2() != null && ( toVendorAddress.getAddress2().trim().length() != 0 ) ){
                formattoVendorAddress.append ( toVendorAddress.getAddress2() );
            }
            if( ( toVendorAddress.getAddress3() != null && !"".equalsIgnoreCase(toVendorAddress.getAddress3().trim()) )
                  || ( toVendorAddress.getAddress4() != null && !"".equalsIgnoreCase(toVendorAddress.getAddress4().trim()) ) ) {
                formattoVendorAddress.append ( "<BR>" );
            }
            if( toVendorAddress.getAddress3() != null && ( toVendorAddress.getAddress3().trim().length() != 0 ) ){
                formattoVendorAddress.append ( toVendorAddress.getAddress3 () );
            }
            if( toVendorAddress.getAddress3() != null && !"".equals(toVendorAddress.getAddress3().trim())
                && toVendorAddress.getAddress4() != null && !"".equals(toVendorAddress.getAddress4().trim())) {
                formattoVendorAddress.append ( ", " );
            }
            if( toVendorAddress.getAddress4() != null && ( toVendorAddress.getAddress4().trim().length() != 0 ) ){
                formattoVendorAddress.append ( toVendorAddress.getAddress4 () );
            }

            StringBuffer cityStateZip = new StringBuffer ( "" );

            if ( toVendorAddress.getCity() != null && !"".equals( toVendorAddress.getCity() ) ) {
                cityStateZip.append ( toVendorAddress.getCity () );
            }

            // toVendorAddress ',' only if city, state, zip are not empty
            if ( toVendorAddress.getCity() != null && !"".equals( toVendorAddress.getCity() )
                 && ( (  toVendorAddress.getState() != null && !"".equals(toVendorAddress.getState()))
                 || ( toVendorAddress.getZipCode()!= null  && !"".equals(toVendorAddress.getZipCode())) ) ) {
                cityStateZip.append ( ", " );
            }

            if ( toVendorAddress.getState() != null && !"".equals( toVendorAddress.getState() ) ) {
                cityStateZip.append( toVendorAddress.getState () );
            }

            // Add '-' only if there is state and Zip also
            if ( toVendorAddress.getState() != null && !"".equals( toVendorAddress.getState() )
                 && toVendorAddress.getZipCode () != null && !"".equals( toVendorAddress.getZipCode () ) ) {
                cityStateZip.append ( " - " );
            }

            if ( toVendorAddress.getZipCode()!= null && !"".equals( toVendorAddress.getZipCode() ) ) {
                cityStateZip.append ( toVendorAddress.getZipCode () );
            }

            // toVendorAddress ',' if any of the above is present
            if ( (  ( toVendorAddress.getCity() != null && !"".equals(toVendorAddress.getCity())  )
                    || ( toVendorAddress.getState() != null && !"".equals(toVendorAddress.getState()) )
                    || ( toVendorAddress.getZipCode() != null &&  !"".equals(toVendorAddress.getZipCode()) ) )
                    && toVendorAddress.getCountry() != null && !"".equalsIgnoreCase( toVendorAddress.getCountry() ) )

            {
                cityStateZip.append ( ", " );
                cityStateZip.append ( toVendorAddress.getCountry () );
            }
            else  if ( toVendorAddress.getCountry() != null && !"".equals(toVendorAddress.getCountry() ) ) // added by sujan on 23rd dec 2004. if city,state,zipcode r empty
            {
                cityStateZip.append ( toVendorAddress.getCountry() );
            }
            if( cityStateZip != null && cityStateZip.toString().trim().length() > 0  )
            {
                formattoVendorAddress.append ( "<BR>" + cityStateZip );
            }

            StringBuffer phFax = new StringBuffer ();

            if( toVendorAddress.getPhoneNumber() != null && !"".equals( toVendorAddress.getPhoneNumber() ) ) {
                phFax.append ( "T: " + toVendorAddress.getPhoneNumber () );
            }

            if( toVendorAddress.getPhoneNumber() != null && !"".equals( toVendorAddress.getPhoneNumber() )
                &&  toVendorAddress.getFaxNumber() != null && !"".equals ( toVendorAddress.getFaxNumber() ) ) {
                phFax.append ( ",&nbsp;" );
            }

            if( toVendorAddress.getFaxNumber() != null && !"".equals( toVendorAddress.getFaxNumber() ) ) {
                phFax.append ( "F: " + toVendorAddress.getFaxNumber () );
            }

            if( phFax != null && phFax.toString().trim().length() > 0  ) {
                formattoVendorAddress.append ( "<BR>" + phFax );
            }

            if(  toVendorAddress.getEmail() != null && toVendorAddress.getEmail().trim().length() > 0 ) {
                formattoVendorAddress.append ( "<BR>" +  "Email: "+ toVendorAddress.getEmail() );
            }

        }

        return formattoVendorAddress.toString();
    }
    public String getShipAlertAsHTML ()
    {
        String shipAlertAsHTML = "";
        if ( shipAlerts != null )
        {
            shipAlertAsHTML = shipAlerts.replaceAll( ",", "<br>" );
        }
        return shipAlertAsHTML;
    }

}